﻿using System;
using System.Threading;
using System.ServiceProcess;

using DreamCube.WebServer.WinServiceModel;
using DreamCube.Foundation.Basic.Utility;

namespace DreamCube.WebServer.WinService
{
    partial class SouthIISKeepLiveServer : ServiceBase
    {
        public SouthIISKeepLiveServer()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 定时器
        /// </summary>
        private KeepLiveServer keepLiveServer = null;
        protected override void OnStart(String[] args)
        {
            try
            {
                if (keepLiveServer == null)
                {
                    //守护windows app
                    keepLiveServer = new KeepWinAppLiveServer();
                    keepLiveServer.Start();
                }
            }
            catch (Exception ex)
            {
                MyLog.MakeLog(ex);
            }
        }

        /// <summary>
        /// 停止服务触发的事件
        /// </summary>
        protected override void OnStop()
        {
            try
            {
                if (keepLiveServer != null)
                    keepLiveServer.Stop();
            }
            catch (Exception ex)
            {
                MyLog.MakeLog(ex);
            }
        }
    }
}
